<?php
require('lib/recaptchalib.php');
require('lib/mysql.class.php');
require('lib/functions.php');
require('lib/simple_html_dom.php');
require('conf.php');

ini_set('max_execution_time', 10800);
//
//$string = file_get_contents('db_sql.txt');
//$arr = unserialize($string);
//
//$id_delete = array();
//
//foreach ($arr as $key=>$value) {
//	$is_null = $db->QuerySingleValue('SELECT `id` FROM `eng_words2` WHERE `name`=\''.$value.'\'');
//	if ($is_null == false)
//	{
//		$id_delete[] = $is_null;
//	}
//}
//
//$deletes = serialize($id_delete);
//file_put_contents('id_to_delete.txt', $deletes);
//echo count($id_delete);
//$translate = array();
//$i = 0;
//$db->Query('SELECT `name`, `id` FROM `eng_words2` WHERE `type` IS NOT NULL');
//$total = $db->RowCount();
//ob_end_flush();
//while (!$db->EndOfSeek()) {
//	$i++;
//	$info = $db->Row();
//	$trans = dict($info->name, 'en', 'ru');
//	$translate[$info->id] = $trans['translate'][0];
//	echo 'Обработано '.$i.' слов из '.$total.'<br>';
//}
//
//$string = serialize($translate);
//file_put_contents('translate.txt', $string);


$str = file_get_contents('translate.txt');
$arr = unserialize($str);
var_dump($arr);
foreach ($arr as $key=>$value) {
	$db->Query('UPDATE `eng_words2` SET `versions`=\''.$value.'\' WHERE `id`='.$key);
}
?>